# -*- coding: utf-8 -*-

#    Copyright (C) 2014 by Promotux
#                       di Francesco Meloni snc - http://www.promotux.it/

#    Author: Francesco Meloni  <francesco@promotux.it>

#    This file is part of OdCollect.

#    OdCollect is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 2 of the License, or
#    (at your option) any later version.

#    OdCollect is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.

#    You should have received a copy of the GNU General Public License
#    along with OdCollect.  If not, see <http://www.gnu.org/licenses/>.

from sqlalchemy import *
from Environment import *

t_ente = Table('ente', meta,
        Column('id', Integer, primary_key=True),
        Column('id_tipo',
                Integer,
                    ForeignKey(fk_prefix_main + "tipo_ente.id",
                    onupdate="CASCADE",
                    ondelete="RESTRICT"),
                nullable=False),
        Column('codice', String(15), nullable=False, unique=True),
        Column('lati', String(25), nullable=True),
        Column('longi', String(25), nullable=True),
        Column('denominazione', String(500), nullable=False,unique=True),
        Column('denominazione_breve', String(10), nullable=False,unique=True),
        Column('data_registrazione', DateTime, nullable=True),
        Column('icona_ente', Text, nullable=True),
        Column('immagine', Text, nullable=True),
        Column('active', Boolean, default=True),
        schema=mainSchema,
        extend_existing=True)
t_ente.create(checkfirst=True)
